import React from 'react';
import { Dialog } from '@teamix/ui';
import { YunxiaoIcon } from '@alife/devops-ui';
import PropTypes from 'prop-types';
import './index.scss';
import intl from '../../locale';

const prefix = 'announcement-card';

export default class AnnouncementCard extends React.Component {
  static propTypes = {
    content: PropTypes.element,
    visible: PropTypes.bool,
    onClose: PropTypes.func,
  };

  static defaultProps = {
    content: intl.get({
      id: 'code-assets.components.announcementCard.AnnouncementContent',
      defaultMessage: '公告内容',
    }),
    visible: true,
  };

  render() {
    const { content, visible, onClose, footer, className } = this.props;

    return (
      <Dialog
        className={`${prefix} ${className}`}
        hasMask={false}
        visible={visible}
        footer={footer || false}
        footerActions={[]}
        animation={false}
      >
        <div className={`${prefix} ${className}`}>
          <a
            className={`${prefix}-icon`}
            onClick={() => {
              onClose();
            }}
          >
            <YunxiaoIcon type="false-line" />
          </a>
          <div className={`${prefix}-container-content`}>
            <div className={`${prefix}-content`}>{content}</div>
          </div>
        </div>
      </Dialog>
    );
  }
}
